package com.xinqi.xinqidev.day20231209jingdong.q1;

import java.util.Scanner;

/**
 * @author xin麒
 * @date 2023/12/9 10:07
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    //
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] split = scanner.nextLine().split(" ");
        int n = Integer.parseInt(split[0]);
        int k = Integer.parseInt(split[1]);
        String s = scanner.nextLine();
        int result = process(n, k, s.toCharArray());
        System.out.println(result);

    }
//5 3
//abaaa
//
// 5 4
//abaaa

    /**
     * aba
     * baa
     * aaa
     * 5-3=2
     * k
     * k / 2 = 3 / 2 = 1
     * <p>
     * 1 - 1 = 0
     * 1 + 1 = 2
     * <p>
     * <p>
     * abaa
     * baaa
     *
     * @param n
     * @param k
     * @param chars
     * @return
     */


    private static int process(int n, int k, char[] chars) {
        int count = 0;

        int flag = k % 2;

        int mid = k / 2;
/*

abaaa
aba
i = 0
base = 1
j = 1
[1 - 1] = [1 + 1]
[0] = [2]

baa

aaa
* */

        if (flag == 1) {
            for (int i = 0; i <= n - k; i++) {
                int base = i + mid;//0 + 1
                int j = mid;//1
                for (; j > 0; j--) {
                    if (chars[base - j] != chars[base + j ]) break;
                }
                if (j != 0) continue;
                count++;
            }
            return count;
        }

        //偶数

        for (int i = 0; i <= n - k; i++) {
            int base = i + mid;
            int j = mid;
            for (; j > 0; j--) {
                if (chars[base - j] != chars[base + j - 1]) break;
            }
            if (j != 0) continue;

            count++;
        }
        return count;
    }
}